﻿namespace KinonekoSoftware.CodariaDB.Core
{
    public abstract class _Full<T> : Engine where T : FullObject
    {
        protected internal override void OnDatabaseOpeningInternal(RepositoryOpenContext context)
        {
            var logger     = context.Logger;
            var repository = context.Repository;
            InsideDB = repository.Get<T>(GetCollectionName());
            logger.Debug($"正在打开数据表:{GetCollectionName()}");
        }

        protected internal override void OnDatabaseClosingInternal(ILogger logger)
        {
            InsideDB = null;
            logger.Debug($"关闭数据表，{GetCollectionName()}");
        }

        protected override void OnDatabaseOpening(RepositoryOpenContext context)
        {

        }

        protected override void OnDatabaseClosing(ILogger logger)
        {
        }


        public abstract string GetCollectionName();
        public ILiteCollection<T> InsideDB { get; private set; }

    }
}